package buco.core.internal;

import java.util.ArrayList;

public class FilterChain<T> {

	private ArrayList<Filter<T>> filters;
	
	public FilterChain() {
		filters = new ArrayList<Filter<T>>();
	}
	
	public void addFilter(Filter<T> filter) { 
		filters.add(filter); 
	}
	
	public T executeChain(T input) {
		T current = input; 
		for(Filter<T> filter : filters) { 
			current = filter.process(current);
		}
		return current;
	}
}
